package com.dtmobile.spark.biz

import org.apache.spark.sql.SparkSession

/**
  * Created by zhoudehu on 2017/5/25/0025.
  */
class Init(SDB: String){
 // var oracle = "jdbc:oracle:thin:@"+ORCAL
  def analyse(implicit sparkSession: SparkSession): Unit ={
    initTable(sparkSession,SDB)
  }



  def initTable(implicit sparkSession: SparkSession,SDB: String): Unit ={

    sparkSession.sql(s"use $SDB")

    // 小区表
    sparkSession.sql("select region,city,frequency,cellid,cellname from h_ltecell").createOrReplaceTempView("ltecell")
    // 公网和专网视图
    sparkSession.sql("select line_name,cell_id,cell_name,city,enodeb_id,enodeb_name,celltype from  gt_publicandprofess_new_cell")
      .createOrReplaceTempView("gt_publicandprofess_new_cell")
    // 配置表
    sparkSession.sql("select a.*, CAST( to_char(balence_userrate,'S999.999') AS float ) balence_userrate_f from gt_capacity_config a ")
      .createOrReplaceTempView("gt_capacity_config")







   /* sparkSession.read.format("jdbc").option("url", s"$oracle")
      .option("dbtable","(select region,city,frequency,cellid,cellname from ltecell) t")
      .option("user", "scott")
      .option("password", "tiger")
      .option("driver", "oracle.jdbc.driver.OracleDriver")
      .load().createOrReplaceTempView("ltecell")*/



  /*  sparkSession.read.format("jdbc").option("url", s"$oracle")
      .option("dbtable","(select line_name,cell_id,cell_name,city,enodeb_id,enodeb_name,celltype from  gt_publicandprofess_new_cell) gt_cell")
      .option("user", "scott")
      .option("password", "tiger")
      .option("driver", "oracle.jdbc.driver.OracleDriver")
      .load().createOrReplaceTempView("gt_publicandprofess_new_cell")

    //配置表
    sparkSession.read.format("jdbc").option("url", s"$oracle")
      .option("dbtable","(select a.*, CAST( to_char(balence_userrate,'S999.999') AS float ) balence_userrate_f from gt_capacity_config a ) T")
      .option("user", "scott")
      .option("password", "tiger")
      .option("driver", "oracle.jdbc.driver.OracleDriver")
      .load().createOrReplaceTempView("gt_capacity_config")*/


  }


}
